<template>
  <div class="app-container">
    <!-- 头部 -->
    <el-row>
      <el-col :span="12">
        <div class="infoTitle">工程信息：</div>
      </el-col>
<!--      <el-col :span="12">-->
<!--        <div class="infoButton">-->
<!--          &lt;!&ndash; 审核通过&ndash;&gt;-->
<!--          <el-popover placement="top" width="160" v-model="visibleSuccess">-->
<!--            <p>确定审核通过吗？</p>-->
<!--            <div style="text-align: right; margin: 0">-->
<!--              <el-button size="mini" type="text" @click="visibleSuccess = false">取消</el-button>-->
<!--              <el-button type="primary" size="mini" @click="checkSuccess">确定</el-button>-->
<!--            </div>-->
<!--            <el-button-->
<!--              type="success"-->
<!--              size="small"-->
<!--              icon="el-icon-check"-->
<!--              slot="reference"-->
<!--              :disabled="disabled">审核通过-->
<!--            </el-button>-->
<!--          </el-popover>-->
<!--              &lt;!&ndash;           审核不通过&ndash;&gt;-->
<!--          <el-popover placement="top" width="160" v-model="visibleFailure"-->
<!--          ><p>确定审核不通过吗？</p>-->
<!--            <div style="text-align: right; margin: 0">-->
<!--              <el-button size="mini" type="text" @click="visibleFailure = false">取消</el-button>-->
<!--              <el-button type="primary" size="mini" @click="checkFailure">确定</el-button>-->
<!--            </div>-->
<!--            <el-button-->
<!--              type="danger"-->
<!--              size="small"-->
<!--              icon="el-icon-close"-->
<!--              slot="reference"-->
<!--              :disabled="disabled">审核不通过-->
<!--            </el-button>-->
<!--          </el-popover>-->
<!--        </div>-->
<!--      </el-col>-->
    </el-row>

    <!-- 工程信息表单 -->
    <template v-if="showEngInfo && engInfo && Object.keys(engInfo).length > 0">
      <el-form  @submit.native.prevent label-position="right" size="small"  :model="engList" style="margin-left: 100px;margin-top: 20px;height: 150px">
        <el-row :gutter="24">
          <el-col :span="5">
            <el-form-item label="工程名称：" prop="engName">
              {{ engList.engName }}
            </el-form-item>
            <el-form-item label="工程编号：" prop="engNo">
              {{ engList.engNo }}
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="档案馆代号：" prop="dangAnGuanNo">
              {{ engList.dangAnGuanNo }}
            </el-form-item>
            <el-form-item label="移交单位：" prop="yiJiaoDanWei">
              {{ engList.yiJiaoDanWei }}
            </el-form-item>
            <el-form-item label="编制单位：" prop="bianZhiDanWei">
              {{ engList.bianZhiDanWei }}
            </el-form-item>
          </el-col>


          <el-col :span="5">
            <el-form-item label="编制开始时间：" prop="bianZhiDateStart">
              {{ engList.bianZhiDateStart }}
            </el-form-item>
            <el-form-item label="编制结束时间：" prop="bianZhiDateEnd">
              {{ engList.bianZhiDateEnd }}
            </el-form-item>
            <el-form-item label="工程地址：" prop="EngAddress">
              {{ engList.EngAddress }}
            </el-form-item>
          </el-col>


          <el-col :span="4">
            <el-form-item label="总投资金额：" prop="engCost">
              {{ engList.engCost }}
            </el-form-item>
            <el-form-item label="案卷数：" prop="AnJuanShu">
              {{ engList.AnJuanShu }}
            </el-form-item>
            <el-form-item label="档案馆名称：" prop="dangAnGuanName">
              {{ engList.dangAnGuanName }}
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="数字化单位：" prop="shuZiHuaDanWei">
              {{ engList.shuZiHuaDanWei }}
            </el-form-item>
            <el-form-item label="文件目录：" prop="fileDirectory">
              {{ engList.fileDirectory }}
            </el-form-item>
            <el-form-item label="创建时间：" prop="creationTime">
              {{ engList.creationTime }}
            </el-form-item>
          </el-col>

        </el-row>
      </el-form>
    </template>
    <template v-else>
      <el-empty description="无工程信息"></el-empty>
    </template>
  </div>
</template>

<script>

import {failPassBEEng, passBEEng} from "@/api/system/eng_af";


export default {
  props: {
    ifDel:Number,
    engInfo: {
      type: Object,
      default: null,
    },
  },
  data() {
    return {
      showEngInfo: true, // 初始化时显示EngInfo组件
      labelPosition:'right',
      engList: {},
      disabled_wan: true,
      disabled_pass: true,
      disabled_forcePass: true,
      disabled_failPass: true,
      visiblePass: false,
      visibleForcePass: false,
      visibleFailPass: false,
      anjuanQueryParams: {
        eeid: null,
      },
    };
  },
  watch: {
    engInfo: {
      immediate: true, // 在组件创建时立即执行一次
      handler(newVal) {
        // 使用对象的深拷贝方式赋值
        this.engList = { ...newVal };
        // 其他子组件的状态重置代码，如果需要的话

        if (this.engInfo && Object.keys(this.engInfo).length > 0) {
          if (this.engList.projectStatus === 0) {
            this.disabled_wan = false;
            this.disabled_pass = true;
            this.disabled_forcePass = true;
            this.disabled_failPass = true;
          } else if (this.engList.projectStatus === 1) {
            this.disabled_pass = false;
            this.disabled_failPass = false;
          }
        } else {
          this.disabled_wan = true;
          this.disabled_pass = true;
          this.disabled_forcePass = true;
          this.disabled_failPass = true;
        }
      },
    },
    ifDel() {
      this.DeleteAll();
    }
  },
  methods: {
    DeleteAll() {
      if(this.ifDel===1){
        this.showEngInfo = false;
        this.engInfo = {};
      }
      else{
        this.showEngInfo = true;
      }
    },

    reset() {
      this.showEngInfo=false;
      // 将子组件的状态重置为初始值
      // this.engList = {};
      this.disabled_wan = true;
      this.disabled_pass = true;
      this.disabled_forcePass = true;
      this.disabled_failPass = true;
      this.visiblePass = false;
      this.visibleForcePass = false;
      this.visibleFailPass = false;

    },

    // //审核通过
    // checkSuccess() {
    //   passBEEng(this.engList)
    //     .then(() => {
    //       this.$message.success("审核通过成功！");
    //       this.engList = {}
    //       this.disabled = true
    //       // 更新界面显示状态
    //       this.visibleSuccess = false;
    //       this.$emit("updateEngInfo");
    //     })
    //     .catch((error) => {
    //       this.$message.error("审核通过失败：" + error);
    //     });
    // },
    // //审核不通过
    // checkFailure() {
    //   failPassBEEng(this.engList)
    //     .then(() => {
    //       this.$message.success("审核不通过成功！");
    //       this.engList = {}
    //       this.disabled = true
    //       // 更新界面显示状态
    //       this.visibleFailure = false;
    //       this.$emit("updateEngInfo");
    //     })
    //     .catch((error) => {
    //       this.$message.error("审核不通过失败：" + error);
    //     });
    // },
  }
};
</script>

<style>
.infoTitle {
  text-align: left;
  font-size: 20px;
  font-weight: bold;
  color: rgb(26, 115, 198);
  white-space: nowrap; /* 让文字不换行，保持在一行内显示 */
}

.infoButton {
  display: flex;
  justify-content: flex-end; /* 靠右对齐 */
  align-items: center;
}

.infoButton button {
  margin-left: 10px; /* 增加左边距 */
  margin-right: 10px; /* 增加右边距 */
}
</style>

